<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<title>审批纪录</title>
    <script src="/Public/Home/js/zepto.min.js"></script>
    <link href="/Public/Home/css/weui.min.css" rel="stylesheet">
	<link rel="stylesheet" href="/Public/Home/SaleManager/stylesheets/index.css">
	<link rel="stylesheet" href="/Public/Home/SaleManager/stylesheets/dropload.css">
</head>
<body>
	<div class="approvalRecord">
		<header class = "all_header">
			<a class = "h_back_1 aproving" style='flex: 1;' data-role-id='<?php echo ($myself["role_id"]); ?>' href="javascript:void(0);"><img src="/Public/Home/SaleManager/images/back_icon.png" alt="" style="width:30px;vertical-align: middle;"></a>
			<span class = "h_title">审批纪录</span>
			<?php if($myself["role_id"] == 0): ?><a class = "h_add" href="javascript:void(0)"></a>
			<?php elseif($myself["role_id"] == 7): ?><a class = "h_add" href="javascript:void(0)"></a>
				<?php else: ?><a class = "h_add" href="/Home/SaleManager/County/appliceSupport.html">申请支持</a><?php endif; ?>
			
		</header>
		<div class="weui-tab">
      <div class="weui-navbar">
        <div class="weui-navbar__item weui-bar__item_on">
            我发起的
        </div>
        <div class="weui-navbar__item">
            待审批
        </div>
        <div class="weui-navbar__item" style = "margin:0 1px;">
            已审批
        </div>
      </div>
      <div class="weui-tab__panel">
				<div class="record_list first" style = "display: block;">
				<?php if(applyByMe != ''): if(is_array($applyByMe)): $i = 0; $__LIST__ = $applyByMe;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><div class="record_w" data-apply-id="<?php echo ($v["id"]); ?>" data-role-id="<?php echo ($myself["role_id"]); ?>" data-apply-status="<?php echo ($v["reply_status"]); ?>" data-apply-applyuser="myself">
						<div class="record_l">
							<h4><?php echo ($v["ctype"]); ?></h4>
							<p class = "record_people"><span>发起人：</span><span><?php echo ($v["apply_name"]); ?></span><span class = "approval_date"><?php echo (date('Y-m-d',$v["apply_time"])); ?></span></p>
						</div>
						<?php switch($v["reply_status"]): case "1": ?><div class="record_r pre_approval">
									<?php echo ($v["apply_cstatus"]); ?>
								</div><?php break;?>
						    <?php case "2": ?><div class="record_r no_approval">
									<?php echo ($v["apply_cstatus"]); ?>
								</div><?php break;?>
						    <?php case "0": ?><div class="record_r next_approval">
									<?php echo ($v["apply_cstatus"]); ?>
								</div><?php break; endswitch;?>
					</div><?php endforeach; endif; else: echo "" ;endif; ?>
				<?php else: ?>
					<div class="no_record">
						<div class="no_img">
							<img src="/Public/Home/SaleManager/images/no_approve.png" alt="">
						</div>
						<div class="no_tips">
							暂无审批纪录
						</div>
					</div><?php endif; ?>
				</div>
				
				
				<div class="record_list second">
					<?php if(waitProve != ''): if(is_array($waitProve)): $i = 0; $__LIST__ = $waitProve;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><div class="record_w" data-apply-id="<?php echo ($v["id"]); ?>" data-role-id="<?php echo ($myself["role_id"]); ?>" data-apply-status="<?php echo ($v["reply_status"]); ?>" >
						<div class="record_l">
							<h4><?php echo ($v["ctype"]); ?></h4>
							<p class = "record_people"><span>发起人：</span><span><?php echo ($v["apply_name"]); ?></span><span class = "approval_date"><?php echo (date('Y-m-d',$v["apply_time"])); ?></span></p>
						</div>
						<?php switch($v["reply_status"]): case "1": ?><div class="record_r pre_approval">
									<?php echo ($v["apply_cstatus"]); ?>
								</div><?php break;?>
						    <?php case "2": ?><div class="record_r no_approval">
									<?php echo ($v["apply_cstatus"]); ?>
								</div><?php break;?>
						    <?php case "0": ?><div class="record_r next_approval">
									<?php echo ($v["apply_cstatus"]); ?>
								</div><?php break; endswitch;?>
					</div><?php endforeach; endif; else: echo "" ;endif; ?>
				<?php else: ?>
					<div class="no_record">
						<div class="no_img">
							<img src="/Public/Home/SaleManager/images/no_approve.png" alt="">
						</div>
						<div class="no_tips">
							暂无审批纪录
						</div>
					</div><?php endif; ?>
				</div>
				<div class="record_list third">
					<?php if(approved != ''): if(is_array($approved)): $i = 0; $__LIST__ = $approved;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><div class="record_w" data-apply-id="<?php echo ($v["id"]); ?>" data-role-id="<?php echo ($myself["role_id"]); ?>" data-apply-status="<?php echo ($v["reply_status"]); ?>">
						<div class="record_l">
							<h4><?php echo ($v["ctype"]); ?></h4>
							<p class = "record_people"><span>发起人：</span><span><?php echo ($v["apply_name"]); ?></span><span class = "approval_date"><?php echo (date('Y-m-d',$v["apply_time"])); ?></span></p>
						</div>
						<?php switch($v["reply_status"]): case "1": ?><div class="record_r pre_approval">
									<?php echo ($v["apply_cstatus"]); ?>
								</div><?php break;?>
						    <?php case "2": ?><div class="record_r no_approval">
									<?php echo ($v["apply_cstatus"]); ?>
								</div><?php break;?>
						    <?php case "0": ?><div class="record_r next_approval">
									<?php echo ($v["apply_cstatus"]); ?>
								</div><?php break; endswitch;?>
					</div><?php endforeach; endif; else: echo "" ;endif; ?>
				<?php else: ?>
					<div class="no_record">
						<div class="no_img">
							<img src="/Public/Home/SaleManager/images/no_approve.png" alt="">
						</div>
						<div class="no_tips">
							暂无审批纪录
						</div>
					</div><?php endif; ?>
				</div>
      </div>
    </div>
	</div>
	<script src = "/Public/Home/SaleManager/js/androidback.js"></script>
	<script src = "/Public/Home/SaleManager/js/index.js"></script>
	<script src = "/Public/Home/SaleManager/js/Common.js"></script>
	<script src = "/Public/Home/SaleManager/js/dropload.min.js"></script>
</body>

<script>
//下拉刷新
var LoadEnd = false;
var itemIndex=0;
// 每页展示10个
var counter=0
var firstcounter = 0;
var secondcounter = 0;
var thiirdcounter = 0;
var num = 10;
var firstpageStart = 0;
var secondpageStart = 0;
var thiirdpageStart = 0;
var pageStart=0;
var dropload =$('.approvalRecord').dropload({
	scrollArea : window,
	loadDownFn : function(me){
		if(counter==0){
			counter++;
			firstcounter++;
			secondcounter++;
			thiirdcounter++;
			firstpageStart = firstcounter*num;
			secondpageStart = secondcounter*num;
			thiirdpageStart = thiirdcounter*num;
             me.resetload();
			return false;
		}
		
		if(itemIndex==0){
			pageStart=firstpageStart;
		}
		if(itemIndex==1){
			pageStart=secondpageStart;
		}
		if(itemIndex==2){
			pageStart=thiirdpageStart;
		}
		// 锁定
        me.lock();
        $.ajax({
            type: 'GET',
            url: '',
            data:{'pageStart':pageStart,'itemIndex':itemIndex},
            dataType: 'json',
            success: function(data){
            		var vhtml='';
            		if(itemIndex==0){
            			firstpageStart = firstcounter*num+1;
            			firstcounter++;
            		}
            		if(itemIndex==1){
            			secondpageStart = secondcounter*num+1;
            			secondcounter++;
            		}
            		if(itemIndex==2){
            			thiirdpageStart = thiirdcounter*num+1;
            			thiirdcounter++;
            		}	
            	 	LoadEnd=true;
            	 	if(data.data==null ||data.data=='undefined'){
            	 		 me.noData();
            	 		 me.unlock()
		                // 代码执行后必须重置
		                 me.resetload();
            	 		 return false;
            	 	}
            	 	$(data.data).each(function(i,val) { 
					if(itemIndex==0){
						vhtml+='<div class="record_w" data-apply-id="'+val.id+'" data-role-id="'+val.role_id+'" data-apply-status="'+val.reply_status+'" data-apply-applyuser="myself">';
					}else{
						vhtml+='<div class="record_w" data-apply-id="'+val.id+'" data-role-id="'+val.role_id+'" data-apply-status="'+val.reply_status+'" >';
					}
            	 		vhtml+='<div class="record_l">';
            	 		vhtml+='<h4>'+val.ctype+'</h4>';
            	 		vhtml+='<p class="record_people"><span>发起人：</span><span>'+val.apply_name+'</span><span class="approval_date">'+val.apply_time+'</span></p>';
            	 		vhtml+='</div>';
            	 		if(val.reply_status==0){  //待审批
            	 			vhtml+='<div class="record_r next_approval">'+val.apply_cstatus+'</div></div>';
            	 		}
					if(val.reply_status==1){  //同意
						vhtml+='<div class="record_r pre_approval">'+val.apply_cstatus+'</div></div>'; 	 			
					            	 		}
					if(val.reply_status==2){	//拒绝
						vhtml+='<div class="record_r next_approval">'+val.apply_cstatus+'</div></div>';
					}
            	 														
				}); 
            	 	if(vhtml!=''){
            	 		if(itemIndex==0){
            	 			$('.first').append(vhtml);
            	 		}
					if(itemIndex==1){
						$('.second').append(vhtml);       	 			
					 }
					if(itemIndex==2){
						$('.third').append(vhtml);	
					}
            	 	}else{
            	 		// 无数据
                     me.noData();
            	 	}
            		me.unlock()
                // 代码执行后必须重置
                me.resetload();
            },
            error: function(xhr, type){
            		me.unlock()
                // 无数据
                me.noData();
                me.resetload();
            }
        });
    }
});

$(".weui-navbar__item").on("click",function () {
	var $that = $(this);
	itemIndex = $that.index();
});
</script>
</html>